CC = gcc
CFLAGS = -O -pipe -W -Wall -Wpointer-arith -Wno-unused-parameter -Wunused-function -Wunused-variable -Wunused-value -Werror -g 
LINK = $(CC)

CORE_DEPS = core/sgc_config.h \
			core/sgc_hash.h \
			core/sgc_list.h \
			core/sgc_log.h \
			core/sgc_inthash.h \
			os/sgc_epoll.h \
			logic/sgc_chat_connections.h \
			logic/sgc_chat_logic_flash.h 

OBJECTS = objs/main.o \
		  objs/sgc_config.o \
		  objs/sgc_hash.o \
		  objs/sgc_list.o \
		  objs/sgc_log.o \
		  objs/sgc_epoll.o \
		  objs/sgc_inthash.o \
		  objs/sgc_chat_connections.o \
		  objs/sgc_chat_logic_flash.o 

sgc : $(OBJECTS)
	  $(LINK) -o sgc $(OBJECTS)
	  mv ./sgc ./bin/sgc

objs/main.o : $(CORE_DEPS) \
		 main.c
		 $(CC) -c $(CFLAGS) \
		 -o objs/main.o \
		 main.c

objs/sgc_config.o : $(CORE_DEPS) \
		 core/sgc_config.c
		 $(CC) -c $(CFLAGS) \
		 -o objs/sgc_config.o \
		 core/sgc_config.c

objs/sgc_hash.o : $(CORE_DEPS) \
		 core/sgc_hash.c
		 $(CC) -c $(CFLAGS) \
		 -o objs/sgc_hash.o \
		 core/sgc_hash.c

objs/sgc_list.o : $(CORE_DEPS) \
		 core/sgc_list.c
		 $(CC) -c $(CFLAGS) \
		 -o objs/sgc_list.o \
		 core/sgc_list.c

objs/sgc_log.o : $(CORE_DEPS) \
		 core/sgc_log.c
		 $(CC) -c $(CFLAGS) \
		 -o objs/sgc_log.o \
		 core/sgc_log.c

objs/sgc_epoll.o : $(CORE_DEPS) \
		 os/sgc_epoll.c
		 $(CC) -c $(CFLAGS) \
		 -o objs/sgc_epoll.o \
		 os/sgc_epoll.c

objs/sgc_inthash.o : $(CORE_DEPS) \
		 core/sgc_inthash.c
		 $(CC) -c $(CFLAGS) \
		 -o objs/sgc_inthash.o \
		 core/sgc_inthash.c
		 
objs/sgc_chat_connections.o : $(CORE_DEPS) \
		 logic/sgc_chat_connections.c
		 $(CC) -c $(CFLAGS) \
		 -o objs/sgc_chat_connections.o \
		 logic/sgc_chat_connections.c
		 
objs/sgc_chat_logic_flash.o : $(CORE_DEPS) \
		 logic/sgc_chat_logic_flash.c
		 $(CC) -c $(CFLAGS) \
		 -o objs/sgc_chat_logic_flash.o \
		 logic/sgc_chat_logic_flash.c

clean : 
		 rm ./bin/sgc $(OBJECTS) 
